module test_linked_list_m

    use load_pif_m, only: load_pif
    use linked_list_nnps_m, only: build => build_list_from_loc, query
    use list_type_m, only: list_t
    use twin_list_type_m, only: twin_list_t
    use testdrive, only: new_unittest, unittest_type, error_type, check
    implicit none
    private

    public :: collect_linked_list

contains

    !> Collect all exported unit tests
    subroutine collect_linked_list(testsuite)
        !> Collection of tests
        type(unittest_type), allocatable, intent(out) :: testsuite(:)

        testsuite = [ &
                    new_unittest("valid", test_valid) &
                    ]

    end subroutine collect_linked_list

    subroutine test_valid(error)
        type(error_type), allocatable, intent(out) :: error
        real, allocatable :: loc(:, :)
        type(list_t), allocatable :: list(:, :)
        type(twin_list_t) :: twin_list

        call load_pif("example/ini_xv.dat", loc)
        call build(loc, 2.5000000E-01, 2, list)
        ! print *, list(2, 1)%items, list(2, 1)%log

        call query(loc, list, 3.0000000E-01, 50, twin_list) !@note: 半径
        call check(error, twin_list%log, 18)
    end subroutine test_valid

end module test_linked_list_m
